package struts.actionForm;

import javax.servlet.http.HttpServletRequest;

import metier.Stage;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class BeanAjoutStage extends ActionForm {
	private static final long serialVersionUID = -4014670435362563747L;
	
	private Stage stage=new Stage();
	private String departements;
	
	public String getDepartements() {
		return departements;
	}

	public void setDepartements(String departements) {
		this.departements = departements;
	}

	public Stage getStage() {
		return stage;
	}

	public void setStage(Stage stage) {
		this.stage = stage;
	}

	public String getNom()
	{
		return stage.getNom();
	}
	
	public void setNom(String nom)
	{
		stage.setNom(nom);
	}
	
	public String getDescription()
	{
		return stage.getDescription();
	}
	
	public void setDescription(String description)
	{
		stage.setDescription(description);
	}

	public BeanAjoutStage() {
		super();
	}

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors erreurs = new ActionErrors();
		
		if(getNom()==null || getNom().trim().equals(""))
			erreurs.add("Champs \"nom\" vide", new ActionMessage("struts.actionForm.BeanAjoutStage.nomVide"));
		
		if(getDescription()==null || getDescription().trim().equals(""))
			erreurs.add("Champs \"description\" vide", new ActionMessage("struts.actionForm.BeanAjoutStage.DescrVide"));		
		
		if(departements.equals(""))
			erreurs.add("Champs \"departement\" vide", new ActionMessage("struts.actionForm.BeanAjoutStage.DepVide"));
		
		return erreurs;
	}
	

}
